package gdr.player;

import java.util.*;
/**
 * Raccoglie un insieme di personaggi in una stessa squadra.
 * @author Giorgio Vitale
 *
 */
public class Team {
	
	protected String name;
	protected ArrayList<DefaultPlayer> players;
	/**
	 * indica se e' il gruppo dell'utente
	 */
	protected boolean isUser = false;
	
	protected ArrayList<Team> ally;
	protected ArrayList<Team> enemy;
	
	public Team() {
		players = new ArrayList<DefaultPlayer>();
		ally = new ArrayList<Team>();
		enemy = new ArrayList<Team>();
		isUser = false;
	}
	
	/**
	 * Verifica se il team e' stato sconfitto oppure no.
	 * @return
	 */
	public boolean isDefeated(){
		for (int i=0; i<players.size(); i++)
			if (players.get(i).getActualStat().getStat(Statistiche.HP)>0) return false;
		return true;
	}

	public boolean equals(Object o)
	{	if (!(o instanceof Team)) return false;
		Team t = (Team)o;
		return name.equals(t.name);
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public ArrayList<DefaultPlayer> getPlayers() {
		return players;
	}

	public void setPlayers(ArrayList<DefaultPlayer> players) {
		this.players = players;
	}
	public boolean isUser() {
		return isUser;
	}
	public void setUser(boolean isUser) {
		this.isUser = isUser;
	}
	public ArrayList<Team> getAlly() {
		return ally;
	}
	public void setAlly(ArrayList<Team> ally) {
		this.ally = ally;
	}
	public ArrayList<Team> getEnemy() {
		return enemy;
	}
	public void setEnemy(ArrayList<Team> enemy) {
		this.enemy = enemy;
	}

	@Override
	public String toString() {
		return "Team [name=" + name + ", players=" + players.size() + "]";
	}
	
	
}
